import { request } from "@/utils/service"
import { getToken } from "@/utils/cache/cookies"
import axios from "axios"
const baseURL = import.meta.env.VITE_BASE_API

/** 增 */
export function createWebSteDataApi(data: any) {
  return request({
    url: "webSet/add",
    method: "post",
    data
  })
}

/** 删 */
export function deleteWebSteDataApi(id: string) {
  return request({
    url: "webSet/del",
    method: "delete",
    params: {
      id
    }
  })
}

/** 改 */
export function updateWebSteDataApi(data: any) {
  return request({
    url: "webSet/update",
    method: "put",
    data
  })
}
/** 改下架套餐 */
export function updateStateDataApi(data: any) {
  return request({
    url: "webSet/updateState",
    method: "put",
    data
  })
}

/** 查 */
export function getWebSteDataApi(params: any) {
  return request({
    url: "webSet/query",
    method: "get",
    params
  })
}

/**宽带上级 */
/** 增 */
export function createWebSteSuperDataApi(data: any) {
  return request({
    url: "webSource/add",
    method: "post",
    data
  })
}

/** 删 */
export function deleteWebSteSuperDataApi(id: string) {
  return request({
    url: "webSource/del",
    method: "delete",
    params: {
      id
    }
  })
}

/** 改 */
export function updateWebSteSuperDataApi(data: any) {
  return request({
    url: "webSource/update",
    method: "put",
    data
  })
}

/** 查 */
export function getWebSteSuperDataApi(params: any) {
  return request({
    url: "webSource/query",
    method: "get",
    params
  })
}

// 增 佣金规则
export function webCommissionAddApi(data: any) {
  return request({
    url: "webCommission/add",
    method: "post",
    data
  })
}
// 查 佣金规则
export function webCommissionQueryApi(params: any) {
  return request({
    url: "webCommission/query",
    method: "get",
    params
  })
}
/**一键复制套餐 */
export function copyWebCombo(id: any) {
  return request<any>({
    url: `webSet/copySet/${id}`,
    method: "get"
  })
}
// 宽带产品下载
export function webdownSet(data: any) {
  return axios({
    url: `${baseURL}/webSet/downSet`,
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
      token: getToken()
    },
    responseType: "blob",
    data
  })
}
